﻿using BluetoothMachine.Enums;
using BluetoothMachine.ExpandHelper;
using BluetoothMachine.GlobalStatics;
using BluetoothMachine.Models;
using Prism.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BluetoothMachine.ViewModels
{
    public class UserManagementViewModel
    {
        public UserGlobal MyUser { get; set; }
        public UserManagementViewModel(UserGlobal userGlobal)
        {
            MyUser = userGlobal;
        }

        public DelegateCommand AddUpdate => new DelegateCommand(() => MyUser.Save());

        public DelegateCommand DeleteData => new DelegateCommand(() => MyUser.Delect());

        public IEnumerable<AuthorityType> Foods
        {
            get
            {
                foreach (AuthorityType c in (AuthorityType[])Enum.GetValues(typeof(AuthorityType)))
                {
                    if ((c != AuthorityType.管理员) && (c != AuthorityType.Null)) yield return c;
                }
            }
        }

        /// <summary>
        /// 双击事件
        /// </summary>
        public DelegateCommand<UserModel> MouseDoubleClick => new DelegateCommand<UserModel>(sender => sender?.UpdateValue(MyUser.User));
    }
}
